#ifndef SCHEMA_H
#define SCHEMA_H

#include <map>
#include <string>
using namespace std;

// forward declarations:
class SchemaComponent;

/*
    Class: Schema
    Represents an SQL Data Base Schema.
*/
class Schema
{
    /* Section: public */
    public:
        /*
            Constructor: Default constructor.
            Initializes the object.
        */
        Schema();

        /*
            Destructor: Default destructor.
            Destroy the object.
        */
        virtual ~Schema();

        /*
            Constructor: Copy constructor.
            Initializes the object as a copy from other Schema object.

            Parameters:
                other - Schema object to copy from.
        */
        Schema(const Schema& other);

        /*
            Method: Add
            Adds a SchemaComponent to the Schema.

            Parameters:
               component - Table or View to add
        */
        void add(SchemaComponent * component);

        /*
            Method: Get

            Parameters:
                name        - Name of the SchemaComponent asked for.
                component   - SchemaComponent asked for. Must be NULL when calling.

            Returns:
                True if the name exists in the Schema and component is the SchemaComponent associated.
                False in other case, so component will be NULL.
        */
        bool get(const string & name, SchemaComponent * & component);

        /*
            Method: ToString.
            Returns:
                A string representation of the Data Base schema.
        */
        string toString();

        /*
            Method: clone
            Returns:
                A clone of this object.
        */
        Schema * clone();

    /* Section: private */
    private:
        /*
            Variable: schema
            Type: map<name, SchemaComponent>
            mapping of the SchemaComponent by its names.
        */
        map<string, SchemaComponent *> * schema;
};

#endif // SCHEMA_H
